package br.com.ravi.deposito.vo;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import br.com.ravi.annotations.RaviMethodSerializator;
import br.com.ravi.annotations.RaviViewSerializator;
import br.com.ravi.deposito.dao.GenericDAO;
import br.com.ravi.deposito.dao.HibernateModel;
import br.com.ravi.enums.RaviMeasureUnit;

import com.google.gson.annotations.SerializedName;

/**
 * 
 * @author Rafael Ingaramo
 * 
 */
@Table(name = "CADCLIENTE")
@Entity(name = "CADCLIENTE")
@RaviViewSerializator
public class CustomerVO extends HibernateModel implements Serializable {
	private static final long serialVersionUID = 1L;
	@SerializedName(value="dcrcliente")
	private String descricaoCliente;
	@SerializedName(value="cnpjcpf")
	private String nmrCnpfCpf;
	@SerializedName(value="nmrrg")
	private String nmrRg;
	@SerializedName(value="ddi")
	private String nmrPhoneDdi;
	@SerializedName(value="ddd")
	private String nmrPhoneDdd;
	@SerializedName(value="phone")
	private String nmrPhone;
	private GenericDAO<CustomerVO> dao;

	@Override
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name="idcadcliente",nullable=false,insertable=true,updatable=false)
	@RaviMethodSerializator(order=-10,isHidden=true,width=0,raviMeasureUnit=RaviMeasureUnit.NONE,jsonDataProperty="id")
	public Long getId() {
		return super.getId();
	}

	@Column(name="dcr_cliente",length=45,nullable=false)
	@RaviMethodSerializator(order=1,label="Cliente",width=150,raviMeasureUnit=RaviMeasureUnit.PIXELS,jsonDataProperty="dcrcliente")
	public String getDescricaoCliente() {
		return descricaoCliente;
	}

	public void setDescricaoCliente(String descricaoCliente) {
		this.descricaoCliente = descricaoCliente;
	}

	@Column(name="nmr_cnpj_cpf",length=14,nullable=false)
	@RaviMethodSerializator(order=2,label="CNPJ/CPF",width=20,raviMeasureUnit=RaviMeasureUnit.PIXELS,jsonDataProperty="cnpjcpf")
	public String getNmrCnpfCpf() {
		return nmrCnpfCpf;
	}

	public void setNmrCnpfCpf(String nmrCnpfCpf) {
		this.nmrCnpfCpf = nmrCnpfCpf;
	}

	@Column(name="nmr_rg",length=14)
	@RaviMethodSerializator(order=3,label="RG",width=20,raviMeasureUnit=RaviMeasureUnit.PIXELS,jsonDataProperty="nmrrg")
	public String getNmrRg() {
		return nmrRg;
	}

	public void setNmrRg(String nmrRg) {
		this.nmrRg = nmrRg;
	}
	
	@Column(name = "nmr_telefone_ddi", length = 3)
	@RaviMethodSerializator(order=4,label="DDI",width=20,raviMeasureUnit=RaviMeasureUnit.PIXELS,jsonDataProperty="ddi")
	public String getNmrPhoneDdi() {
		return nmrPhoneDdi;
	}

	public void setNmrPhoneDdi(String nmrPhoneDdi) {
		this.nmrPhoneDdi = nmrPhoneDdi;
	}

	@Column(name = "nmr_telefone_ddd", length = 3)
	@RaviMethodSerializator(order=5,label="DDD",width=20,raviMeasureUnit=RaviMeasureUnit.PIXELS,jsonDataProperty="ddd")
	public String getNmrPhoneDdd() {
		return nmrPhoneDdd;
	}

	public void setNmrPhoneDdd(String nmrPhoneDdd) {
		this.nmrPhoneDdd = nmrPhoneDdd;
	}

	@Column(name = "nmr_telefone", length = 20)
	@RaviMethodSerializator(order=6,label="Telefone",width=100,raviMeasureUnit=RaviMeasureUnit.PIXELS,jsonDataProperty="phone")
	public String getNmrPhone() {
		return nmrPhone;
	}

	public void setNmrPhone(String nmrPhone) {
		this.nmrPhone = nmrPhone;
	}

	@Override
	@Transient
	public GenericDAO<?> getDAO() {
		if (this.dao == null) {
			this.dao = new GenericDAO<CustomerVO>(CustomerVO.class);
		}

		return this.dao;
	}
}